Files

A file is an external permanent object stored in a file system. Files are accessed in T via ports. Ordinarily, files are sequences of characters, similar to strings. An input port open on an existing file delivers successive characters (or lines, or parsed objects) out of the file. An output port open on a new file deposits successive characters (or lines, or printed representations of objects) into the file.

OPEN and MAYBE-OPEN obtain ports which access files. Any port created by OPEN or MAYBE-OPEN should be closed (using the CLOSE operation, page [*]) when no further access to the file is required. This is guaranteed if OPEN and MAYBE-OPEN are always used in conjunction with WITH-OPEN-PORTS (page [*]), which ensures that any port opened actually gets closed, even if there is a throw out of the body of the WITH-OPEN-PORTS form.


\begin{inset}{}
Opens an external file for reading or for writing, and returns
a...
...ORT (OPEN file.txt '(IN)))) \\
\> (READ-LINE PORT))
\end{tabbing}}
\end{inset}


\begin{inset}{}
Like {\tt OPEN}, but returns false if for any reason it
cannot open the file.
\end{inset}

Operation


\begin{inset}{}
\index{PORT-NAME@{\tt PORT-NAME}}
Returns the filename of the fi...
...d ports other than
those created by {\tt OPEN} and {\tt MAYBE-OPEN}.
\end{inset}


\begin{inset}{}
Returns true if the specified file exists.
\end{inset}


\begin{inset}{}
Moves the file named by {\it source-filespec\/} to a new locatio...
...t all versions of {\bf T} 3.1 implement {\tt FILE-MOVE}.
\end{inset}\end{inset}


\begin{inset}{}
Deletes the specified file.
\begin{inset}{Bug:}
Not all versions of {\bf T} 3.1 implement {\tt FILE-DELETE}.
\end{inset}\end{inset}